//读取COOKIE
function GetCookieData(sL)
{
    var sRet="";
    var sC=""+document.cookie;
    if(sC.length>0)
    {
        var aC=sC.split(";",100);
        var iC=aC.length;
        for(var i=0;i<iC;i++)
        {
            if(aC[i].indexOf(sL+"=")!=-1)
            {
                var aRet=aC[i].split("=");
                sRet=unescape(aRet[1]);
                break;
            }
        }
    }
    return sRet;
} 

function LoginCookie()
{

	if(UrlWhere!=0 ){
		ThisArray[4] = window.location.href.replace(/\//g,"%2F").replace(/\:/,"%3A").replace(/\=/,"%3D").replace(/\?/,"%3F");
	}

	var TempLogin,strTemp,temp;
	TempLogin=document.getElementById("Login");
	if(typeof(TempLogin)  !=   "object"){return;}

	var strName_1 = "";
	strName_1 = "Keepname";

	if( checkLoginIf() )
		temp= GetCookieData(strName_1) + '(<a href="/users/manage.php" >会员中心</a>) <a href="/users/LoginOut.php">退出</a>';
	else
	{
		temp= GetCookieData(strName_1)+' <a href="/users/Login.php?goBackUrl='+(ThisArray[4]==""?ThisArray[UrlWhere]:ThisArray[4])+'">登录</a> | <a href="/users/register.php">注册</a>';
	}
	document.write(temp);
	return;
}
function checkLoginIf(){
	if( GetCookieData("Myname")!="")
		return true;
	else
		return false;
}


function LoginCenter()
{
	var TempLogin,strTemp,temp,month;
	LoginCookie();
	TempLogin=document.getElementById("username");
	if(GetCookieData("PHPSESSID")!="" && GetCookieData("cdb_auth")!="" && GetCookieData("Myname")!="")
		temp= GetCookieData("Keepname");
	else
		temp='游客';
	TempLogin.innerHTML=temp;
	
	var myDate = new Date();
	month = myDate.getMonth()+1;
	DayName=new Array("日","一","二","三","四","五","六");
	document.getElementById("date").innerHTML=myDate.getFullYear()+"年"+month+"月"+myDate.getDate()+"日 （星期" + DayName[myDate.getDay()] +"）";
	
}

function LoginNewsCookie()
{

	if(UrlWhere!=0 ){
		ThisArray[4] = window.location.href.replace(/\//g,"%2F").replace(/\:/,"%3A").replace(/\=/,"%3D").replace(/\?/,"%3F");
	}
	
	var TempLogin,strTemp,temp;
	TempLogin=document.getElementById("Login");
	if(typeof(TempLogin)  !=   "object"){return;}

	var strName_1 = "";
	strName_1 = "Keepname";


	if( checkLoginIf() ){
		temp= '<strong>'+GetCookieData(strName_1) + '</strong>' + '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/users/manage.php" >会员中心</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/users/LoginOut.php">退出</a>';
	}else{
		temp= '<strong>'+GetCookieData(strName_1) + '</strong>' + '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/users/Login.php?goBackUrl='+(ThisArray[4]==""?ThisArray[UrlWhere]:ThisArray[4])+'">登录</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/users/register.php">注册</a>';
	}
	document.write(temp);
	return;
}





var UrlWhere = -1;
//var ThisArray = ["http%3A%2F%2Fwww.landtu.com%2F","http%3A%2F%2Fwww.landtu.com%2Fabroad%2F","http%3A%2F%2Fwww.landtu.com%2Fdomestic%2F","http%3A%2F%2Fwww.landtu.com%2Faround%2F"];
var ThisArray = ["%2Fusers%2Fmanage.php","%2Fabroad","%2Fdomestic","%2Faround",""];

function ShowNav()
{
	if(UrlWhere=="-1") return; 
	var a = document.getElementById('head').getElementsByTagName("DT");
	if(UrlWhere<a.length)
		a[UrlWhere].className = a[UrlWhere].className==""?"stop":"stop1";
}

/* 新的头部 */
function ShowNewNav()
{
	if(UrlWhere=="-1") return; 
	var a = document.getElementById('nav').getElementsByTagName("LI");
	if(UrlWhere<a.length)
		a[UrlWhere].className = "current";
}



function SetReferer(){
	if(GetCookieData("HttpReferer")==""){
		Set("HttpReferer",document.referrer);
	}
}

function Set(Key,value){
	document.cookie = Key+"="+value+";path=/;";
}

function getOs() 
{ 
	var OsObject = ""; 
	if(navigator.userAgent.indexOf("MSIE")>0) { 
		return "MSIE"; 
	} 
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
		return "Firefox"; 
	} 
	if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
		return "Safari"; 
    }  
	if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
		return "Camino"; 
	} 
	if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
		return "Gecko"; 
	} 
} 


function SetVacationVisitCookie(ThisId,ThisName)
{
	var TempSearchKey_id = new Array();
	var TempSearchKey_name = new Array();

    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
	
	var haveGet = false;
	for(var i=0; i<6; i++){
		TempSearchKey_id[i] = GetCookieData("VacationSearchKey"+i+"Id");
		TempSearchKey_name[i] = GetCookieData("VacationSearchKey"+i+"Name");
		
		if(TempSearchKey_id[i]==ThisId){
			haveGet = true;
		}
	}
	if(!haveGet){
		for(var i=5; i>0; i--){
			TempSearchKey_id[i] = TempSearchKey_id[i-1];
			TempSearchKey_name[i] = TempSearchKey_name[i-1];			
		}
		TempSearchKey_id[0] = ThisId;
		TempSearchKey_name[0] = ThisName;	
		
		for(var i=0; i<6; i++){
			document.cookie = "VacationSearchKey"+i+"Id"+"="+escape(TempSearchKey_id[i])+";expire="+ exp.toGMTString()+";path=/;";
			document.cookie = "VacationSearchKey"+i+"Name"+"="+escape(TempSearchKey_name[i])+";expire="+ exp.toGMTString()+";path=/;";
		}	
	}
	ShowVacationCookie();
}
function ShowVacationCookie()
{
	var TempSearchKey_id = new Array();
	var TempSearchKey_name = new Array();
	for(var i=0; i<6; i++){
		TempSearchKey_id[i] = GetCookieData("VacationSearchKey"+i+"Id");
		TempSearchKey_name[i] = GetCookieData("VacationSearchKey"+i+"Name");
	}
	
	var tempHtml ="";
	//tempHtml = "<ul>";
	for(var i=0; i<6; i++){
		tempHtml += '<div class="p_l_l_li"><a href="/vacation/'+TempSearchKey_id[i]+'.html">'+TempSearchKey_name[i]+'</a></div>';
	}	
	//tempHtml += "</ul>";
	document.getElementById("historyList").innerHTML = tempHtml;	

}

